import { FC } from "react";
import QuestionInputConf, { QuestionInputPropsType } from "./QuestionInput";
import QuestionTitleConf, { QuestionTitlePropsType } from "./QuestionTitle";

// 统一各个组件的prop type
export type ComponentPropsType = QuestionInputPropsType &
  QuestionTitlePropsType;

// 统一定义组件的配置
export type ComponentConfigType = {
  title: string;
  type: string;
  Component: FC<ComponentPropsType>;
  defaultProps: ComponentPropsType;
};
// 全部的组件配置的列表
const componentConfList: ComponentConfigType[] = [
  QuestionInputConf,
  QuestionTitleConf,
];
export function getComponentConfByType(type: string) {
  return componentConfList.find((item) => item.type === type);
}
